package com.wxb.controller;

import com.wxb.common.core.web.controller.BaseController;
import com.wxb.common.core.web.domain.AjaxResult;
import com.wxb.domain.MallBrandEntity;
import com.wxb.service.IMallBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Date 2025-05-30 17:05
 * @Version 1.0
 * @Description
 * @ClassName MallBrandController
 **/
@RestController
@RequestMapping("/brand")
public class MallBrandController extends BaseController {
    @Autowired
    private IMallBrandService brandService;

    /**
     * 分页获取品牌
     */
    @GetMapping("list")
    public Object list(@RequestParam(value = "page") Integer page,
                       @RequestParam(value = "size") Integer size) {
        //查询列表数据
        Map<String, Object> params = new HashMap<>();
        params.put("fields", "id, name, floor_price, app_list_pic_url");
        params.put("sidx", "id");
        params.put("order", "asc");
        startPage();
        List<MallBrandEntity> brandEntityList = brandService.queryList(params);
        return getDataTable(brandEntityList);
    }

    /**
     * 品牌详情
     */
    @GetMapping("detail")
    public Object detail(@RequestParam(value = "id") Integer id) {
        Map<String, Object> resultObj = new HashMap<>();
        //查询列表数据
        MallBrandEntity entity = brandService.queryObject(id);
        //
        resultObj.put("brand", entity);
        return AjaxResult.success(resultObj);
    }
}
